<?php

/**
 *  找回密码
*/

namespace app\api\controller;
use app\facade\Basic;
use think\Request;
use app\api\service\Retrieve as ServiceRetrieve;

class Retrieve extends BaseController
{

    /**
     *  获取邮箱验证码
    */
    public function getEmailCode(Request $request)
    {
        $param['email'] = $request->param('email');

        /* 验证 */
        $this->validateData($param,'Retrieve.getEmailCode');

        $serviceRetrieve = new ServiceRetrieve();
        $result = $serviceRetrieve->getEmailCode($param);

        return Basic::json($result);
    }

    /**
     *   验证邮箱验
     */
    public function emailVerify(Request $request)
    {

        $param['email'] = $request->param('email');

        /* 验证 */
        $this->validateData($param,'retrieve.verify');

        return ServiceRetrieve::emailVerify($param);

    }

    /**
     *   修改密码
    */
    public function password(Request $request)
    {
        $param['email'] = $request->param('email');
        $param['code'] = $request->param('mail_code');
        $param['password'] = $request->param('password');

        /* 验证 */
        $this->validateData($param,'retrieve.password');

        $serviceRetrieve = new ServiceRetrieve();
        $result = $serviceRetrieve->password($param);

        return Basic::json($result);

    }

}